package com.nit.tools.loop;


import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;


/**
 * 循环工具 NitLoopTools
 *
 * @Auth: 逆天开源-逍遥哥哥
 * @link 1715656022@qq.com
 * @Date: 2023-07-11
 */
public final class NitLoopTools {
    /**
     * @param cycles   循环次数
     * @param callBack fuction函数
     */
    public static void loop(int cycles, NitLoopCallBack callBack) {
        for (int i = 0; i < cycles; ++i) {
            callBack.call();
        }
    }


    public static String loop(int cyckes, Supplier supplier) {
        return (String) Stream.generate(supplier).limit(cyckes).collect(Collectors.joining());
    }
}
